package com.td.evo;

import java.util.Date;

import com.krakers.evo.TestEvolution;
import com.krakers.evo.log.EvolutionLogic;
import com.krakers.evo.log.select.RouletteSelector;
import com.krakers.evo.log.select.TournamentSelector;
import com.td.evo.log.cross.TDNullCrosser;
import com.td.evo.log.cross.TDSimplePathCrosser;
import com.td.evo.log.eval.TDPathEvaluator;
import com.td.evo.log.mutate.TDNullMutator;
import com.td.evo.log.mutate.TDSimplePathMutator;
import com.td.evo.obj.factory.TDPathFactory;

public class TDPathEvolution extends TestEvolution {

	long time = 0;
	
	public TDPathEvolution(int size) {
		super(size);
		setFactory(new TDPathFactory());
		setEvaluator(new TDPathEvaluator());
		setSelector(new TournamentSelector());
		setCrosser(new TDSimplePathCrosser(20));
		setMutator(new TDNullMutator());// TDSimplePathMutator(11, 0.1));
	}

	@Override
	protected void initHook() {
		time -= new Date().getTime();
	}
	
	@Override
	protected void endHook() {
		
		time += new Date().getTime();
		
		while(population.size() > 0) {
			int indx = EvolutionLogic.getMaxSpecieIndx(population);
			System.out.println(population.get(indx));
			population.remove(indx);
		}
		
		System.out.println("Time: " + time/1000 + "s");
	}
	
	public static void main(String[] str) {
		System.out.println("==========  10  ==========");
		new TDPathEvolution(10).run(50);
//		System.out.println("==========  20  ==========");
//		new TDPathEvolution(20).run(50);
//		System.out.println("==========  50  ==========");
//		new TDPathEvolution(50).run(50);
//		System.out.println("=========  100  ==========");
//		new TDPathEvolution(100).run(50);
	}
}